package com.xcf.controller.business.consign;


import java.lang.reflect.Field;
import java.net.URLDecoder;
import java.sql.Connection;
import java.sql.DriverManager;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.xcf.controller.base.BaseController;
import com.xcf.entity.Page;
import com.xcf.service.business.consign.ConsignInputService;
import com.xcf.util.Jurisdiction;
import com.xcf.util.PageData;
import com.xcf.util.Tools;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;

/** 
 * 类名称：ConsignInputController
 * 创建人：Micro Chen
 * 更新时间：2017年11月07日
 * @version
 */
@Controller
@RequestMapping(value="/consignMgr")
public class ConsignInputController extends BaseController {
	
	String menuUrl = "consignMgr/consignInput"; //菜单地址(权限用)	

		
	    @Autowired
		private ConsignInputService consignInputService;
	    
	    
		//托单
		@RequestMapping(value = "/consignInput")
	    public ModelAndView show() throws Exception {
			
	        ModelAndView mv = this.getModelAndView();
	        PageData pd = new PageData();
	        pd = this.getPageData();	       
	        mv.setViewName("business/consign/consignInput");
	        mv.addObject("pd", pd);
	        return mv;
	    }
		//出口
		@RequestMapping(value="/consignWEBill")
		public ModelAndView showWE() throws Exception{
			 ModelAndView mv =this.getModelAndView();
			 PageData pd = new PageData();
			 pd = this.getPageData();	       
			 mv.setViewName("business/consign/consignWEBill");
			 mv.addObject("pd", pd);
			 return mv;
		}
		//进口
		@RequestMapping(value="/consignWIBill")
		public ModelAndView showWI() throws Exception{
			 ModelAndView mv =this.getModelAndView();
			 PageData pd = new PageData();
			 pd = this.getPageData();
			 pd.put("businessType", 2);
			 mv.setViewName("business/consign/consignWIBill");
			 mv.addObject("pd", pd);
			 return mv;
		}
		//内贸
		@RequestMapping(value="/consignNMBill")
		public ModelAndView showNM() throws Exception{
			 ModelAndView mv =this.getModelAndView();
			 PageData pd = new PageData();
			 pd = this.getPageData();	       
			 mv.setViewName("business/consign/consignNMBill");
			 mv.addObject("pd", pd);
			 return mv;
		}
		

	    /**
	     * 已录入托单查询
	     * @param page
	     * @param request
	     * @param response
	     * @throws Exception
	     */
	    @RequestMapping(value="/getTradeListForImport")	   
		public void getTradeListForImport(Page page,HttpServletRequest request,HttpServletResponse response)throws Exception{
	    	   
		        PageData pd = new PageData();
		        pd = this.getPageData();
		        
		        page.setPd(pd);
				JSONObject obj = new JSONObject();
				List<PageData>	tradeList = consignInputService.getTradeListForImport(page);	
				
				JSONArray json = new JSONArray();
	            for(PageData p : tradeList){
	                JSONObject jo = new JSONObject();
	                jo.put("trade_code", p.getString("BILL_CODE"));	
	                jo.put("agency_self_no", p.getString("SHIPPER_NUM"));	
	                jo.put("input_date", p.get("CREATE_TIME")!=null?p.get("CREATE_TIME").toString():"");	
	                jo.put("agency_man", p.getString("SHIPPER_NAME"));	
	                jo.put("port_of_discharge", p.getString("PORT_DISCHARGE"));	
	                jo.put("stop_harbour", p.getString("RIVER_DELIVERY"));	
	                json.add(jo);
	            }
	            response.setContentType("text/html; charset=utf-8");
				response.getWriter().write(json.toString());				
				response.getWriter().flush();
		      
	      }
	    
	        /**
	         * 获取销售人员
	         * @param page
	         * @param request
	         * @param response
	         * @throws Exception
	         */
	        @RequestMapping(value="/getSalesPerson")	   
	 		public void getSalesPerson(Page page,HttpServletRequest request,HttpServletResponse response)throws Exception{
	 	    	   
	 		        PageData pd = new PageData();
	 		        pd = this.getPageData();
	 		       
	 	            page.setPd(pd);
	 				JSONObject obj = new JSONObject();
	 				List<PageData>	salesList = consignInputService.getSalesPerson(page);
	 				JSONArray json = new JSONArray();
	 	            for(PageData p : salesList){
	 	                JSONObject jo = new JSONObject();
	 	                jo.put("id_", p.get("SALER_ID"));
	 	                jo.put("name_", p.getString("SALER_NAME"));
	 	                jo.put("idname", p.get("SALER_ID")+"@"+p.getString("SALER_NAME"));
	 	                jo.put("department", p.getString("DEPARTMENT"));	        
	 	                jo.put("company_name", p.getString("COMPANY"));	        
	 	                jo.put("company_code", p.getString("COMPANY_ID"));
	 	                jo.put("departmentid", p.getString("DEPARTMENT_ID"));	        
	 	                json.add(jo);
	 	            }
	 	            response.setContentType("text/html; charset=utf-8");
	 				response.getWriter().write(json.toString());	 				
	 				response.getWriter().flush();
	 		      
	 	    }
	      
	       /**
	        * 获取客户信息
	        * @param page
	        * @param request
	        * @param response
	        * @throws Exception
	        */
	       @RequestMapping(value="/getCustomer")	
	      public void getCustomer(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	    	   
	    	    PageData pd = new PageData();
		        pd = this.getPageData();
		        page.setPd(pd);
				List<PageData>	customerList = consignInputService.getCustomer(page);
				JSONArray json = new JSONArray();
	            for(PageData p : customerList){
	                JSONObject jo = new JSONObject();
	                jo.put("id_", p.get("ID"));
	                jo.put("ac", p.get("STATUS"));
	                jo.put("customer_name", p.getString("ENTITIES_FULLNAME"));
	                jo.put("customer_code", p.getString("ENTITIES_CODE"));	
	                jo.put("full_name", p.getString("ENTITIES_FULLNAME"));
	                jo.put("cq_code", p.getString("ENTITIES_CODE"));	 
	                jo.put("work_man", p.getString("BUSINESS_CONTACT"));	        
	                jo.put("work_phone", p.getString("BUSINESS_CONTACT_PHONE"));	        
	                jo.put("customer_type", p.getString("ENTITIES_CLASS"));
	                jo.put("nm_account_type", p.getString("SETTLEMENT_CATEGORY"));
	                jo.put("short_name", p.getString("ENTITY_ABBREVIATED"));
	                
	                json.add(jo);
	            }
	            response.setContentType("text/html; charset=utf-8");
				response.getWriter().write(json.toString());	 				
				response.getWriter().flush();
	      }
	      /**
	       * 获取箱主信息
	       * @param page
	       * @param request
	       * @param response
	       * @throws Exception
	       */
	       @RequestMapping(value="/getBoxMaster")	
		   public void getBoxMaster(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
		    	   
		    	    PageData pd = new PageData();
			        pd = this.getPageData();
			        page.setPd(pd);
					JSONObject obj = new JSONObject();
					List<PageData>	boxMasterList = consignInputService.getBoxMaster(page);
					JSONArray json = new JSONArray();
		            for(PageData p : boxMasterList){
		                JSONObject jo = new JSONObject();
		                jo.put("id_", p.get("ID"));
		                jo.put("spell_code", p.get("INDEX_CODE"));
		                jo.put("cq_code", p.getString("OWNER_CODE"));	        
		                jo.put("full_name", p.getString("OWNER_NAME"));	        
		                jo.put("BILL_REQUIREMENT", p.getString("BILL_REQUIREMENT"));	        
		                jo.put("OCE_COLLECT_REMARK", p.getString("OCE_COLLECT_REMARK"));
		                jo.put("ENABLE", p.getString("ENABLE"));
		                jo.put("SETTLEMENT_CATEGORY", p.getString("SETTLEMENT_CATEGORY"));	       
		                jo.put("ENAME", p.getString("ENAME"));	       
		                jo.put("SHORT_NAME", p.getString("SHORT_NAME"));
		                jo.put("remark", p.getString("SEA_BOOKING_OPTION"));
		                json.add(jo);
		            }
		            response.setContentType("text/html; charset=utf-8");
					response.getWriter().write(json.toString());	 				
					response.getWriter().flush();
		      }
	       
	        /**
	         * 获取货源信息
	         * @param page
	         * @param request
	         * @param response
	         * @throws Exception
	         */
	       @RequestMapping(value="/getGoodsSourceCombo")	
		   public void getGoodsSourceCombo(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
		    	   
		    	    PageData pd = new PageData();
			        pd = this.getPageData();
					JSONObject obj = new JSONObject();
					List<PageData>	goodSourceList = consignInputService.getGoodsSourceCombo(page);
					JSONArray json = new JSONArray();
		            for(PageData p : goodSourceList){
		                JSONObject jo = new JSONObject();
		             
		                jo.put("id", p.get("id"));
		                jo.put("goods_type_name_code", p.get("goods_type_code")+"@"+p.get("goods_type_name"));
		                jo.put("goods_type_name", p.get("goods_type_name"));	        
		                jo.put("ord_num", p.get("ord_num"));	        
		                jo.put("enable", p.get("enable"));
		                json.add(jo);
		            }
		            response.setContentType("text/html; charset=utf-8");
					response.getWriter().write(json.toString());	 				
					response.getWriter().flush();
		}
	    /**
	     * 获取国内港口信息
	     * @param page
	     * @param request
	     * @param response
	     * @throws Exception
	     */
	    @RequestMapping(value="/getInlandHarbor")  
	    public void getInlandHarbor(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception {
	        PageData pd = new PageData();
	        pd = this.getPageData();
	        page.setPd(pd);
			JSONObject obj = new JSONObject();
			List<PageData>	inlandHarborList = consignInputService.getInlandHarbor(page);
			JSONArray json = new JSONArray();
            for(PageData p : inlandHarborList){
                JSONObject jo = new JSONObject();
       
                jo.put("id_", p.get("ID"));
                jo.put("FAST_SEARCH_CODE", p.get("FAST_SEARCH_CODE"));
                jo.put("harbour_name", p.get("HARBOR_NAME"));
                jo.put("HARBOR_ENGLISH_NAME", p.get("HARBOR_ENGLISH_NAME"));
                jo.put("english_name", p.get("PORT_ENGLISH_NAME"));
                jo.put("mileage", p.get("MILEAGE"));
                jo.put("area_name", p.get("PORT"));
                jo.put("EDI_CODE", p.get("EDI_CODE"));	        
                jo.put("custom_code", p.get("CUSTOMS_CODE"));	  
                jo.put("ABBREVIATION", p.get("ABBREVIATION"));
                jo.put("ENABLE", p.get("ENABLE"));
                jo.put("SHORE", p.get("SHORE"));	        
                jo.put("SUBDIVIDE_SHORE_CODE", p.get("SUBDIVIDE_SHORE_CODE"));	  
            
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    /**
	     * 获取国外港口信息
	     * @param page
	     * @param request
	     * @param response
	     * @throws Exception
	     */
	    @RequestMapping(value="/getForeignHarbour")  
	    public void getForeignHarbour(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception {
	        PageData pd = new PageData();
	        pd = this.getPageData();
	        if(pd.getString("keyword")!=null&&pd.getString("keyword").contains("'")){
	        	pd.put("keyword", pd.getString("keyword").replace("\'", "_"));
	        }
	        page.setPd(pd);
			JSONObject obj = new JSONObject();
			List<PageData>	inlandHarborList = consignInputService.getForeignHarbour(page);
			JSONArray json = new JSONArray();
            for(PageData p : inlandHarborList){
                JSONObject jo = new JSONObject();
           
                jo.put("id_", p.get("ID"));
                jo.put("FAST_SEARCH_CODE", p.get("FAST_SEARCH_CODE"));
                jo.put("habour_code", p.get("PORT_CODE"));	        
                jo.put("harbour_name", p.get("PORT_ENGLISH_NAME"));
                jo.put("PORT_CHINESE_NAME", p.get("PORT_CHINESE_NAME"));
                jo.put("COUNTRY_ABBREVIATION", p.get("COUNTRY_ABBREVIATION"));
                jo.put("country_code", p.get("COUNTRY_CODE"));
                jo.put("chinese_country", p.get("COUNTRY_CHINESE_NAME"));
                jo.put("COUNTRY_ENGLISH_NAME", p.get("COUNTRY_ENGLISH_NAME"));                
                jo.put("ENABLE", p.get("ENABLE"));     
            
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    @RequestMapping(value="/getCurrentTime")
	    public void getCurrentTime(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	    	SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	    	Date date = new Date();
	    	String sd = df.format(date);
	    	JSONObject jo = new JSONObject();
	    	jo.put("key", sd);
	        response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(jo.toString());	 				
			response.getWriter().flush();
	    }
	    @RequestMapping(value="/getCountryNames")
	    public void getCountryNames(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
	        page.setPd(pd);
			JSONObject obj = new JSONObject();
			List<PageData>	countryNamesList = consignInputService.getCountryNames(page);
			JSONArray json = new JSONArray();
            for(PageData p : countryNamesList){
                JSONObject jo = new JSONObject();           
                
                jo.put("id_", p.get("ID"));
                jo.put("FAST_SEARCH_CODE", p.get("FAST_SEARCH_CODE"));
                jo.put("PORT_CODE", p.get("PORT_CODE"));	        
                jo.put("country_code", p.get("EXPORT_COUNTRY_CODE"));
                jo.put("country_eng_name", p.get("ENGLISH_NAME"));
                jo.put("country_ch_name", p.get("CHINESE_NAME"));
                jo.put("ENABLE", p.get("ENABLE"));                
            
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }  
	    
	    
	    @RequestMapping(value="/getGoodsSource")
	    public void getGoodsSource(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
	        page.setPd(pd);
			JSONObject obj = new JSONObject();
			List<PageData>	goodsSourceList = consignInputService.getGoodsSource(page);
			JSONArray json = new JSONArray();
            for(PageData p : goodsSourceList){
                JSONObject jo = new JSONObject();           
                
                jo.put("id_", p.get("ID"));
                jo.put("spell_code", p.get("SPELL_CODE"));              
                jo.put("source_code", p.get("SRC_PLACE_CODE"));
                jo.put("source_place", p.get("SRC_PLACE_NAME"));
                jo.put("enable", p.get("ENABLE"));                
        
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    
	    @RequestMapping(value="/getTrailerInfo")
	    public void getTrailerInfo(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
	        page.setPd(pd);
			JSONObject obj = new JSONObject();
			List<PageData>	trailerInfoList = consignInputService.getTrailerInfo(page);
			JSONArray json = new JSONArray();
            for(PageData p : trailerInfoList){
            	String trailerType="";
            	String devanType="";
            	if(p.get("TRAILER_TYPE")!=null && p.get("TRAILER_TYPE").equals(1))
            	{
            		trailerType="目的港拖车";
            	}else{
            		trailerType="起运港拖车";
            	}
            	if(p.get("PACKING_TYPE")!=null && p.get("PACKING_TYPE").equals(1))
            	{
            		devanType="装箱";
            	}else{
            		devanType="拆箱";
            	}
                JSONObject jo = new JSONObject();
                String trailerDate ="";
                if(p.get("TRAILER_DATE")!=null){
                	trailerDate=p.get("TRAILER_DATE").toString();
                }             	
                jo.put("id_", p.get("ID"));
                jo.put("BILL_CODE", p.get("BILL_CODE"));
                jo.put("trailer_type", trailerType);	        
                jo.put("devanning_type", devanType);
                jo.put("trailer_remarks", p.get("REMARK"));
                jo.put("return_box_address", p.get("RETCONTAINERADDR"));
                jo.put("trailer_address", p.get("TRAILER_ADDR"));
                jo.put("trailer_date", trailerDate);
                jo.put("trailer_price", p.get("TRAILER_PRICE"));
                jo.put("trailer_contact", p.get("CONTACT_PERSON"));
                jo.put("trailer_contact_info", p.get("CONTACT_INFO"));
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    
	    @RequestMapping(value="/getSubsupplier")
	    public void getSubsupplier(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
	        page.setPd(pd);
			List<PageData>	supplierList = consignInputService.getSupplierList(page);
			JSONArray json = new JSONArray();
            for(PageData p : supplierList){
       
                JSONObject jo = new JSONObject();
                //jo.put("id_", p.get("BOAT_ID"));
                //jo.put("river_boat_code", p.get("RIVER_BOAT_CODE"));
                //jo.put("river_boat_name", p.get("RIVER_BOAT_NAME"));	        
                jo.put("settle_company", p.get("SETTLE_COMPANY"));            
                jo.put("settle_department_search_code", p.get("SETTLE_DEPARTMENT_SEARCH_CODE"));
                //jo.put("remark", p.get("REMARK"));
                //jo.put("enable", p.get("ENABLE")); 
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    @RequestMapping(value="/getTransportItem")
	    public void getTransportItem(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
	        page.setPd(pd);
			List<PageData>	transportItemList = consignInputService.getTransportItem(page);
			JSONArray json = new JSONArray();
            for(PageData p : transportItemList){
                JSONObject jo = new JSONObject();
                jo.put("id_", p.get("ID"));
                jo.put("spell_code", p.get("FAST_SEARCH_CODE"));
                jo.put("start_item", p.get("START_CLAUSE"));	        
                jo.put("end_item", p.get("END_CLAUSE"));            
                jo.put("transport_item", p.get("START_CLAUSE").toString().concat("--").concat(p.get("END_CLAUSE").toString()));
                jo.put("remark", p.get("REMARK"));
                //jo.put("ENABLE", p.get("ENABLE")); 
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    @RequestMapping(value="/getBoxType")
	    public void getBoxType(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
			JSONObject obj = new JSONObject();
			List<PageData>	boxTypeList = consignInputService.getBoxType(page);
			JSONArray json = new JSONArray();
	
            for(PageData p : boxTypeList){
                JSONObject jo = new JSONObject();           
                
                jo.put("id_", p.get("ID"));
                jo.put("box_edi_code", p.get("BOX_TYPE_CODE"));
                jo.put("box_type_name", p.get("BOX_TYPE_NAME"));	        
                jo.put("box_code", p.get("BOX_TYPE_ABBREIATION"));
               
                jo.put("enable", p.get("ENABLE"));                
            
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    @RequestMapping(value="/getPackaging")
	    public void getPackaging(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
	        page.setPd(pd);
			JSONObject obj = new JSONObject();
			List<PageData>	packagingList = consignInputService.getPackaging(page);
			JSONArray json = new JSONArray();
	          for(PageData p : packagingList){
	              JSONObject jo = new JSONObject();           
	              
	              jo.put("id_", p.get("ID"));
	              jo.put("spell_code", p.get("FAST_SEARCH_CODE"));
	              jo.put("packaging", p.get("PACKAG_METHOD"));	        
	              jo.put("enable", p.get("ENABLE"));
	              jo.put("remark", p.get("REMARK"));
	            
	          
	              json.add(jo);
	          }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    /**
	     * 提单编号
	     * @param page
	     * @param request
	     * @param response
	     * @throws Exception
	     */
	    @RequestMapping(value="/getBolType")
	    public void getBolType(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
			JSONObject obj = new JSONObject();
			List<PageData>	bolTypeList = consignInputService.getBolType(page);
			JSONArray json = new JSONArray();
            for(PageData p : bolTypeList){
                JSONObject jo = new JSONObject();           
                
                jo.put("bol_type_id", p.get("ID")+"@"+p.get("LADING_BILL_TYPE"));
                jo.put("bol_type", p.get("LADING_BILL_TYPE"));
                //jo.put("LADING_BILL_NUMBER", p.get("LADING_BILL_NUMBER"));  
                jo.put("enable", p.get("ENABLE"));             
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    @RequestMapping(value="/getGateUnit")
	    public void getGateUnit(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
	        page.setPd(pd);
			JSONObject obj = new JSONObject();
			List<PageData>	gateUnitList = consignInputService.getGateUnit(page);
			JSONArray json = new JSONArray();
            for(PageData p : gateUnitList){
                JSONObject jo = new JSONObject();           
                jo.put("id_", p.get("ID"));
                jo.put("spell_code", p.get("FAST_SEARCH_CODE"));
                jo.put("gate_name", p.get("CUSTOMS_BROKER_NAME"));	        
                jo.put("remark", p.get("REMARK"));
                //jo.put("ENABLE", p.get("ENABLE"));
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    //报关方式
	    @RequestMapping(value="/getCustomsClearance")
	    public void getCustomsClearance(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
	
			List<PageData>	customsClearanceList = consignInputService.getCustomsClearance(page);
			JSONArray json = new JSONArray();
	
            for(PageData p : customsClearanceList){
                JSONObject jo = new JSONObject(); 
                jo.put("id_", p.get("ID"));
                //jo.put("FAST_SEARCH_CODE", p.get("FAST_SEARCH_CODE"));
                jo.put("id",p.get("ID")+"@"+p.get("CUSTOMS_DECLARATION_MODE"));
                jo.put("customs_clearance_way", p.get("CUSTOMS_DECLARATION_MODE"));
                //jo.put("ENABLE", p.get("ENABLE"));
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    @RequestMapping(value="/getDangerous")
	    public void getDangerous(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
	        page.setPd(pd);
			List<PageData>	dangerousList = consignInputService.getDangerous(page);
			JSONArray json = new JSONArray();
            for(PageData p : dangerousList){
                JSONObject jo = new JSONObject();
                jo.put("id_", p.get("id"));
                jo.put("dangerous_name", p.get("dangerous_name"));
                jo.put("dangerous_type", p.get("dangerous_type"));
                jo.put("main_level", p.get("main_level"));
                jo.put("internal_code", p.get("internal_code"));
                jo.put("international_code", p.get("international_code"));
                json.add(jo);                
               
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    /**
	     * 货物种类
	     * @param page
	     * @param request
	     * @param response
	     * @throws Exception
	     */
	    @RequestMapping(value="/getGoodsTypeName")
	    public void getGoodsTypeName(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
			JSONObject obj = new JSONObject();
			List<PageData>	goodsTypeNameList = consignInputService.getGoodsTypeName(page);
			JSONArray json = new JSONArray();
            for(PageData p : goodsTypeNameList){
                JSONObject jo = new JSONObject();           
                
                jo.put("id_", p.get("ID"));
                jo.put("goods_category_code", p.get("GOODS_CATEGORY_CODE"));
                jo.put("goods_type_name", p.get("GOODS_TYPE_NAME"));   
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    
	   
	    private void getBoxList(List<Map<String,String>> list,Object key,String val,String boxType,String billCode)
	    {
	    	if(val.equals("")) return;
	    	String [] arr =val.split(";");	    	
	    	String [] boxTypes = boxType.split("&&");//1X40OT&&1X40HC&&2X20FL
	    	Map<String, String> map =new HashMap<String,String>();
	    	for(String item:boxTypes)
	    	{
	    		map.put("bill_code", billCode);
	    		map.put("box_type",item.split("X")[1]);
	    	}
	    	
	    	for(int k=0;k<arr.length;k++){
	    		String param = arr[k].split("!")[1];
	    		
	    		   
   					String unitArr[] = StringUtils.splitPreserveAllTokens(param,",");
   					for(int i=0;i<unitArr.length;i++)
   					{
   						if(!"".equals(unitArr[i])&& !"undefined".equals(unitArr[i]))
   						{
   							//箱量,长，宽，高，左超，右超，前超，后超，超限，超高，体积
   							switch(i){
   							case 0:
   								map.put("box_num", unitArr[i]);
   								break;
   							case 1:
   								map.put("box_length", unitArr[i]);
   								break;
   							case 2:
   								map.put("box_width", unitArr[i]);
   								break;
   							case 3:
   								map.put("box_height", unitArr[i]);
   								break;
   							case 4:
   								map.put("left_over", unitArr[i]);
   								break;
   							case 5:
   								map.put("right_over", unitArr[i]);
   								break;
   							case 6:
   								map.put("before_over", unitArr[i]);
   								break;
   							case 7:
   								map.put("behind_over", unitArr[i]);
   								break;
   							case 8:
   								map.put("over_height", unitArr[i]);
   								break;
   							case 9:
   								map.put("over_limit", unitArr[i]);
   								break;
   							case 10:
   								map.put("capacity", unitArr[i]);
   								break;
   							}
   						}else{
   							switch(i){
   							case 0:
   								//map.put("box_num", null);
   								break;
   							case 1:
   								map.put("box_length", null);
   								break;
   							case 2:
   								map.put("box_width", null);
   								break;
   							case 3:
   								map.put("box_height", null);
   								break;
   							case 4:
   								map.put("left_over", null);
   								break;
   							case 5:
   								map.put("right_over", null);
   								break;
   							case 6:
   								map.put("before_over", null);
   								break;
   							case 7:
   								map.put("behind_over", null);
   								break;
   							case 8:
   								map.put("over_height", null);
   								break;
   							case 9:
   								map.put("over_limit", null);
   								break;
   							case 10:
   								map.put("capacity", null);
   								break;
   							}
   						}
   					}
   					list.add(map);
	    	}
	    }
	    
	    private Map<String, String> getTailerItem(List<Map<String,String>> list,Object key,int index)
	    {
	    	Map<String,String> map = new HashMap<String,String>();;
	    	if(list.size()>index){
	    		map = list.get(index);
	    	}
			return map;
	    }
	    private Object convertKey(Object key){
	            Object convertKey="";
				if(key.equals("trailerType")){
					convertKey= "TRAILER_TYPE";
   				
			    }else if(key.equals("devanningType")){
			    	convertKey="PACKING_TYPE";
   				
        	   }else if(key.equals("trailerAddress")){
        		    convertKey="TRAILER_ADDR";
   				
	        	}else if(key.equals("trailerRemarks")){
	        		convertKey="REMARK";
	   				
	        	}else if(key.equals("returnBoxAddress")){
	        		convertKey="RETCONTAINERADDR";
	   				
	        	}else if(key.equals("trailerDate")){
	        		convertKey="TRAILER_DATE";
	   				
	        	}else if(key.equals("trailerPrice")){
	        		convertKey="TRAILER_PRICE";
	   				
	        	}else if(key.equals("trailerContact")){
	        		convertKey="CONTACT_PERSON";
	   				
	        	}else if(key.equals("trailerContactInfo")){
	        		convertKey="CONTACT_INFO";	   				
	        	}
				return convertKey;
	    }
	    private void getTrailerList(List<Map<String,String>> list,Object key,String val,String billCode)
	    {
	    	 if(!"".equals(val))
	    	 {

		   			 String [] arr =  val.split("!@");
		   			 for(int i=0;i<arr.length;i++)
		   			 {
		   				
		   				Map<String,String> map = getTailerItem(list,convertKey(key),i);
		   				if(convertKey(key).equals("")) return;
		   				if(map.get(convertKey(key))==null)
		   				{
		   					map.put(convertKey(key).toString(), arr[i]);
		   					map.put("BILL_CODE", billCode);
		   					if(list.size()>i)list.remove(i);
		   					list.add(i, map);
		   				}

		   			 }
	        	}
	    }
	
	    @RequestMapping(value="/consignAdd")
	    public void consignAdd(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	    	
	    	try{
	    		
	        PageData pd =  new PageData();
	        pd=this.getPageData();
	        String billCode ="";
	        String cnBusTypeName="";
	        
	        	Map<String, String> param = new HashMap<String, String>();
	        	String busType="";
	        	
	        	if(pd.getString("businessType").equals("1"))
	        	{
	        		busType="WE";// --出口
	        		cnBusTypeName="出口";
	        	}else if(pd.getString("businessType").equals("2"))
	        	{
	        		busType="WI";//进口
	        		cnBusTypeName="进口";
	        	}else if(pd.getString("businessType").equals("3")){
	        		busType="JX";//沿江下水
	        		cnBusTypeName="沿江下水";
	        	}else if(pd.getString("businessType").equals("4")){
	        		busType="JS";//沿江上水
	        		cnBusTypeName="沿江上水";
	        	}else if(pd.getString("businessType").equals("5")){
	        		busType="HX";//沿海下水
	        		cnBusTypeName="沿海下水";
	        	}else if(pd.getString("businessType").equals("6")){
	        		busType="HS";//沿海上水
	        		cnBusTypeName="沿海上水";
	        	}else{
	        		busType="QT";//其他
	        		cnBusTypeName="其他";
	        	}
	        	
	        	String companyName= pd.getString("salesManAgent").split("@")[1];
	        	String companySellCode="";
	        	if(companyName.indexOf("重庆")>-1){
	        		companySellCode="CKG";
	        	}else if(companyName.indexOf("上海")>-1){
	        		companySellCode="SHA";
	        	}else if(companyName.indexOf("成都")>-1){
	        		companySellCode="CHD";
	        	
	        	}else if(companyName.indexOf("武汉")>-1){
	        		companySellCode="WUH";
	        	}
	            param.put("CompanySpellCode", companySellCode);
	            param.put("BusinessType", busType);
	            billCode = JSONObject.fromObject(consignInputService.getFlowNumber(param)).get("billCode").toString();	      
	       
	        pd.put("billCode", billCode);
	     
	        
	        pd.put("BUSINESS_TYPE_ID", pd.getString("businessType"));
	        pd.put("BUSINESS_TYPE", cnBusTypeName);
	        
	        String isTrailer="";//0默认，1自拖车2委托拖车
	      
	        Object [] arr= pd.entrySet().toArray();
	        List<Map<String,String>> trailerList= new ArrayList<Map<String, String>>();
	        List<Map<String,String>> trailerList1= new ArrayList<Map<String, String>>();
	        List<Map<String,String>> boxList= new ArrayList<Map<String, String>>();
	        
	        String oog="";
	        String teu="";
	        
	        for(int i=0;i<arr.length;i++)
	        {
	        	Map<String,Object> map = Tools.objectToMap(arr[i]);
	           Object key = map.get("key");
	           String val =map.get("value").toString();
	           String idField = "";
	           String textField = "";
	            
	            
	            getTrailerList(trailerList,key,val,billCode);
	            if(key.equals("aa")) getBoxList(boxList,key,val,pd.getString("boxType"),pd.getString("billCode"));
	           
	            if(!"".equals(val) && val.indexOf("!@")<0)
	            {
	            	String [] el = val.split("@");
	            	
	   	             if(el.length==2)
	   	             {
	   	            	idField = el[0];
	   	                textField = el[1];
	   	             }else{
	   	            	idField = el[0];
	   	             }
	   	            if(key.equals("isTrailer"))
		           	{   isTrailer=idField;
		           		pd.put("IS_ARRANGE_TRAILER", idField);
		           	}else if(key.equals("salesManName"))
	            	{
	            		pd.put("SALER_ID", idField);
	            		pd.put("SALER_NAME", textField);
	            		
	            	}else if(key.equals("salesManDep"))
	            	{
	            		pd.put("DEPARTMENT_ID", idField);
	            		pd.put("DEPARTMENT", textField);
	            	}else if(key.equals("agencyMan"))//托运人
	            	{
	            		pd.put("SHIPPER_ID", idField);
	            		pd.put("SHIPPER_NAME", textField);
	            		
	            	}else if(key.equals("isHBL"))
	            	{
	            		   pd.put("HBL_SEND_TYPE_ID", idField);
	                       pd.put("HBL_SEND_TYPE", textField);
	            	
	            	}else if(key.equals("isTaoyue"))//y
	            	{
	            		if("y".equals(idField))
	            		{
	            			pd.put("ISSET_ABOUT", 1);
	            		}else
	            		{
	            			pd.put("ISSET_ABOUT", 0);
	            		}
	            		
	            	}else if(key.equals("agencyMan"))//托运人
	            	{
	            		pd.put("AGENCY_MAN_ID", idField);
	            		pd.put("AGENCY_MAN", textField);
	            		
	            	}else if(key.equals("agencyContact"))//货主名称
	            	{
	            		pd.put("CONSIGNOR_ID", idField);
	            		pd.put("CONSIGNOR_NAME", textField);
	            		
	            	}else if(key.equals("agencySelfNo"))//托运人自编号
	            	{
	            		pd.put("SHIPPER_NUM", idField);
	            	}else if(key.equals("contact"))//托运人联系人
	            	{
	            		pd.put("SHIPPER_CONTACT", idField);	            		
	            		
	            	}else if(key.equals("payWay"))
	            	{
	            		pd.put("PAYMENT_METHOD", idField);
	            	}else if(key.equals("clientType"))
	            	{
	            		pd.put("CLENT_TYPE", idField);
	            	}else if(key.equals("contactInfo"))
	            	{	            		
	            		pd.put("SHIPPER_CONTACT_WAY", idField);//联系方式 
	            	}else if(key.equals("boxMaster"))//箱主
	            	{
	                    pd.put("CONTAINER_OWNER_KEY", idField);
	            		pd.put("CONTAINER_OWNER", textField);
	            	}else if(key.equals("invoiceNo"))
	            	{
	            		pd.put("INVOICE_NUM", idField);
	            	}else if(key.equals("supplyOfGoods"))
	            	{
	            		pd.put("GOODS_TYPE_CODE", idField);
	            		pd.put("GOODS_TYPE_NAME", textField);
		            	//pd.put("GOODS_TYPE_CODE", textField);
	            		
	            	}else if(key.equals("forwarder_man"))
	            	{
	            		
	            		pd.put("FORWARDER_CUSTOMER_SERVICE", idField);
	            	}else if(key.equals("shipper"))//
	            	{	            		
	            		pd.put("SEND_CONSIGNOR", idField);
	            	}else if(key.equals("boxMasterRemark"))
	            	{
	            		pd.put("SHIPPING_COMPANY_BOOK_NOTE", idField);
	            		
	            	}else if(key.equals("consignee"))
	            	{
	            		pd.put("CONSIGNEE", idField);
	            	}else if(key.equals("goodsSign"))
	            	{
	            		pd.put("SHIPPING_MARK", idField);
	            	}else if(key.equals("noticeMan"))
	            	{
	            		pd.put("NOTIFIER", idField);
	            	}else if(key.equals("goodsEnglishName"))
	            	{
	            		pd.put("GOODS_DESCRIPTION", idField);
	            	}else if(key.equals("tradeMode"))
	            	{
	            		pd.put("TRADE_METHOD", idField);
	            	}else if(key.equals("partialFlag"))//可否分批
	            	{
	            		pd.put("IS_BATCH", idField);
	            	}else if(key.equals("changeShipFlag"))//可否转船
	            	{
	            		pd.put("IS_TRANSSHIP", idField);
	            	}else if(key.equals("portOfLoading"))
	            	{
	            		pd.put("PORT_LOADING_ID", idField);
	            		pd.put("PORT_LOADING", textField);
	            	}else if(key.equals("portOfDischarge"))//目的港
	            	{
	            		pd.put("PORT_DISCHARGE_ID", idField);
	            		pd.put("PORT_DISCHARGE", textField);
	            	}else if(key.equals("placeOfDelivery"))
	            	{
	            		pd.put("PLACE_DELIVERY_ID", idField);
	            		pd.put("PLACE_DELIVERY", textField);
	            	}else if(key.equals("loadHarbour"))
	            	{
	            		pd.put("RIVER_LOAD_ID", idField);
	            		pd.put("RIVER_LOAD", textField);
	            	}else if(key.equals("stopCountry"))//目的国家
	            	{
	            		pd.put("DESTINATION_COUNTRY_ID", idField);
	            		pd.put("DESTINATION_COUNTRY", textField);
	            	}else if(key.equals("goodsSource"))//境内货源地
	            	{
	            		pd.put("TERRITORY_GOODS_SUPPLY_ID", idField);
	            		pd.put("TERRITORY_GOODS_SUPPLY", textField);
	            	}else if(key.equals("goodsChineseName"))//中文品名
	            	{
	            		pd.put("CHINESE_NAME", idField);
	            	}else if(key.equals("hsCode"))
	            	{
	            		pd.put("HS_CODE", idField);
	            	}else if(key.equals("goodsMeasurment"))//托单货物体积
	            	{
	            		pd.put("VOLUME", idField);
	            	}else if(key.equals("goodsPkgs"))//货物件数
	            	{
	            		pd.put("GOODS_NUM", idField);
	            	}else if(key.equals("goodsPackage"))
	            	{
	            		pd.put("UNIT", idField);
	            	
	            	}else if(key.equals("goodsWeight"))
	            	{
	            		pd.put("GOODS_GROSS_WEIGHT", idField);
	            	}else if(key.equals("loadDate"))
	            	{
	            		pd.put("ESTIMATE_RIVER_BOAT_TIME",idField);//预计江船装船时间
	            	}else if(key.equals("shipLine"))
	            	{
	            		pd.put("APPOINT_SHIP_ROUTE", idField);//指定海船航线
	            	}else if(key.equals("putBoxDate"))//放箱时间
	            	{
	            		pd.put("ESTIMATE_TIME", idField);
	            		
	            	}else if(key.equals("pickBoxDate"))//预约摆箱时间
	            	{
	            		pd.put("ESTIMATE_EXTRACT_BOX_TIME", idField);
	            	}else if(key.equals("shippingDate"))//指定预计海船期
	            	{
	            		
	            		pd.put("APPOINT_ESTIMATE_SHIP_TIME", idField);
	            	}else if(key.equals("preSeashipStopDate"))//指定预计海船到港期
	            	{
	            		pd.put("APPOINT_ESTIMATE_SHIP_EXPIRE_TIME", idField);
	            	}else if(key.equals("bolType"))//提单类型
	            	{
	            		pd.put("BILL_TYPE_ID", idField);
	            		pd.put("BILL_TYPE", textField);
	            	
	            	}else if(key.equals("boxType"))//箱型确定
	            	{
	            		pd.put("BOX_TYPE_CONFIRM", idField);
	            	}else if(key.equals("specifiedBox"))
	            	{
	            		pd.put("IS_APPOINT_USERBOX", idField);//0否，1是，2自备箱
	            	}else if(key.equals("boxNo"))//箱号
	            	{
	            		pd.put("CONTAINER_NO", idField);
	            	}else if(key.equals("freeDayRemark"))
	            	{
	            		pd.put("CLIENT_FREE_HEAP_TIME", idField);//客户免堆期
	            	}else if(key.equals("goodsType"))//货物种类
	            	{
	            	
	            		pd.put("GOODS_TYPE", idField);
	            		
	            	}else if(key.equals("priceSource")) //0 销售拿价 1  自拿价 2市场报价  
	            	{
	            		pd.put("PRICE_SOURCE", idField);
	            	}else if(key.equals("enquiryNo"))//报价编号
	            	{
	            		pd.put("OFFER_NUM", idField);
	            	}else if(key.equals("priceRemarks"))//价格备注
	            	{
	            		pd.put("PRICE_REMARK", idField);
	            	}else if(key.equals("yueHao"))//船公司约号
	            	{
	            		pd.put("BOAT_COMPANY_ADVANCE_NUM", idField);
	            	}else if(key.equals("priceAmount"))//船公司订舱价格
	            	{
	            		pd.put("BOAT_COMPANY_BOOK_PRICE", idField);
	            	}else if(key.equals("priceStartDate"))//价格开始时间
	            	{
	            		pd.put("PRICE_START_TIME", idField);
	            	}else if(key.equals("priceEndDate"))//价格结束时间
	            	{
	            		pd.put("PRICE_STOP_TIME", idField);
	            	}else if(key.equals("transportItem"))//运输条款
	            	{
	            		pd.put("TRANSPORT_CLAUSE_ID", idField);
	            		pd.put("TRANSPORT_CLAUSE", textField);
	            		
	            		String sc= textField.split("--")[0];
	            		String ec=textField.split("--")[1];
	            		pd.put("START_TRANSPORT_CLAUSE", sc);
	            		pd.put("END_TRANSPORT_CLAUSE",ec);
	            	}else if(key.equals("carriageType"))//运费条款
	            	{
	            		pd.put("FREIGHT_CLAUS", idField);	            		
	            	}else if(key.equals("feeItem"))//其他运费条款
	            	{
	            		pd.put("OTHER_FREIGHT_CLAUSE", idField);
	            	}else if(key.equals("isBuyClass"))//是否买舱
	            	{
	            		pd.put("IS_BUY_CLASS", idField);
	            	}else if(key.equals("gateType"))
	            	{
	            		
	            		//pd.put("CUS_MOD_ID", idField);
	            		pd.put("CUS_MOD", idField);
	            	}else if(key.equals("gateUnit"))
	            	{
	  
	            		pd.put("CUS_BRO_ID", idField);
	            		pd.put("CUS_BRO", textField);
	            	}else if(key.equals("gateNum"))
	            	{
	            		pd.put("CUSTOMS_NUM", idField);
	            	}else if(key.equals("sjNum"))
	            	{
	            		pd.put("COMMODITY_INSPECTION_NUM", idField);
	            	}else if(key.equals("customDistrict"))//申请地海关
	            	{
	            		pd.put("DECLARATION_CUMTOMS", idField);
	            	}else if(key.equals("gateRemark"))
	            	{
	            		pd.put("DECLARE_CUSTOMS_REQUIRE", idField);
	            	}else if(key.equals("insurance"))//办理保险
	            	{
	            		pd.put("AGENCY_INSURANCE", idField);
	            	}else if(key.equals("bxmc"))
	            	{
	            		pd.put("INSURANCE_NAME", idField);//保险名称
	            	}else if(key.equals("bxje"))
	            	{
	            		pd.put("INSURANCE_AMOUNT", idField);//保险金额
	            	}else if(key.equals("bxbl"))
	            	{
	            		pd.put("INSURANCE_RATE", idField);
	            	}else if(key.equals("bz"))//保险备注
	            	{
	            		pd.put("INSURANCE_REMARK", idField);
	            	}else if(key.equals("loadType0"))//厂装
	            	{
	            		pd.put("IS_FACTORYPACKING", idField);
	            	}else if(key.equals("loadType1"))//港装
	            	{
	            		pd.put("IS_HARBOURPACKING", idField);////
	            	}else if(key.equals("isStifling"))//y
	            	{
	            		if("y".equals(idField)){
	            		pd.put("IS_FUMIGATION", 1);
	            		}else{
	            		  pd.put("IS_FUMIGATION", 0);
	            		}
	            	}
	            	else if(key.equals("remarks")){
	            		pd.put("OPERATION_REMARK", idField);
	            	}else if(key.equals("secondSalesAgent"))
	            	{
	            		pd.put("SEC_SALE_STAFF_REGION_ID", idField);
	            		pd.put("SEC_SALE_STAFF_REGION", textField);
	            	}else if(key.equals("cNum")){	            		
	            		pd.put("FEW", idField);
	            	}else if(key.equals("harbourVolume")){	            		
	            		pd.put("HARBOURVOLUME", idField);
	            	}else if(key.equals("hBoxType")){//指定用箱箱型
	            		pd.put("APPOINT_USERBOX_TYPE", idField);
	            	}else if(key.equals("startInputTime")){
	            		
	            		pd.put("START_INPUT_TIME", idField);	
	            	}else if(key.equals("endInputTime")){//object
	            		pd.put("END_INPUT_TIME", idField);	
	            	}else if(key.equals("dangerousType")){//危险品类别
	            		pd.put("DANGEROUSTYPE", idField);
	            	}//else if(key.equals("tradeFlag")){
	            		
//	            	}else if(key.equals("searchNoticeMan")){
//	            		
//	            	}
	   	            else if(key.equals("loadBox0")){//厂装箱型箱量
	   	            	
	   	            	pd.put("FACTORY_CONTAINER_TYPE_NUM", idField);
	            	}else if(key.equals("loadBox1")){//港装港装箱型箱量
	            		pd.put("PORT_CONTAINER_TYPE_NUM", idField);
	            	}else if(key.equals("salesManAgent")){
	            		pd.put("REGION_ID", idField);
	            		pd.put("REGION", textField);
	            	}else if(key.equals("harbourKg")){//港装货物毛重
	            		pd.put("HARBOURKG", idField);
	            	}else if(key.equals("trailerContact")){//拖车联系人
	            	
	            		pd.put("CONTACT_PERSON", idField);
	            	}else if(key.equals("harbourDate")){//装箱时间
	            		
	            		pd.put("TRAILER_DATE", idField);
	            	}else if(key.equals("seaShipStop")){//海船卸区
	            		pd.put("SEA_UNLOAD_ID", idField);
	            		pd.put("SEA_UNLOAD", textField);
	            		
	            	}else if(key.equals("loadBoxRemark")){//港装要求	            		
	            		pd.put("PORT_LOAD_REQUIREMENTS", idField);
	            	}else if(key.equals("sealNo")){	            		
	            		pd.put("SEAL_NO", idField);
	            	}

	            	else if(key.equals("hasIPPC")){//y木质包装是否有IPPC标准
	            	    
	            		pd.put("HAS_IPPC", idField);
	            		
	            	}else if(key.equals("dangerousName")){
	            		pd.put("DANGEROUS_NAME", idField);	            		
	            	}else if(key.equals("internalCode")){
	            		pd.put("INTERNAL_CODE", idField);	            		
	            	}else if(key.equals("placeOfReceipt")){
	            		
	            		pd.put("SEA_RECEIPT_ID", idField);
	            		pd.put("SEA_RECEIPT", textField);	    
	            	}else if(key.equals("secondSalesMan")){//第二销售人员
	            		pd.put("SEC_SALER_ID", idField);
	            		pd.put("SEC_SALER_NAME", textField);	
	            	}else if(key.equals("coldRem")){//冷藏温度	            		
	            		pd.put("COLD_REM", idField);
	            	}else if(key.equals("internationalCode")){	            		
	            		pd.put("INTERNATIONAL_CODE", idField);
	            	}else if(key.equals("trailerContactInfo")){	            		
	            		pd.put("CONTACT_INFO", idField);
	            	}
//	            	else if(key.equals("searchConsignee")){
//	            		
//	            	}
	            	else if(key.equals("gateUnit")){
	            		pd.put("CUS_BRO_ID", idField);
	            		pd.put("CUS_BRO", textField);	    
	            	}else if(key.equals("woodenPacking")){
	            		
	            		pd.put("IS_WOODEN_PACK", idField);
	            	}else if(key.equals("bigBox")){
	            		pd.put("FORTY_GP", idField);
	            	}else if(key.equals("smallBox")){
	            		pd.put("TWENTY_GP", idField);
	            	}else if(key.equals("bigbigBox")){
	            		pd.put("FORTY_FIVE", idField);
	            	}else if(key.equals("bigBoxH")){
	            		pd.put("FORTY_HP", idField);
	            	}else if(key.equals("teu")){
	            		pd.put("TEU", idField);
	            	}else if(key.equals("specialbox"))
	            	{
	            		pd.put("SPECIAL_CONTAINER", idField);
	            	}
//	            	else if(key.equals("salesManAgentShow")){
//	            		
//	            	}
	            	else if(key.equals("riverLoad")){
	            	      pd.put("RIVER_PORT_ID",idField);
	                      pd.put("RIVER_PORT",textField);
	            		
	            	}else if(key.equals("goodsType")){
	            		
	            		pd.put("GOODS_TYPE", idField);
	            		
	            	}else if(key.equals("returnBoxAddress")){//还箱地
	            		
	            		pd.put("RETCONTAINERADDR", idField);
	            	}else if(key.equals("orderDate")){//?
	            		
	            		pd.put("ENTRUST_TIME", idField);
	            		
	            	}else if(key.equals("orderBoxDate")){//约摆箱时间
	            		pd.put("APPOINT_PUT_CONTAINER_TIME",idField);	            		
	            	}
//	            	else if(key.equals("searchShipper")){
//	            		
//	            	}
	            	else if(key.equals(" preSeashipStopDate")){//指定预计海船到港期
	            		
	            	  pd.put("APPOINT_ESTIMATE_SHIP_EXPIRE_TIME", idField);	         
	            	}else if(key.equals("typeShipping")){
	            		
	            		pd.put("TRANSPORT_METHOD", idField);	        
	            	}else if(key.equals("notifierMscCode")){//通知人msccode
	            		
	            		pd.put("NOTIFY_MSC_CODE", idField);	
	            	}else if(key.equals("dangerousLevel")){//危险品等级
	            		
	            		pd.put("DANGEROUS_LEVEL", idField);	
	            	}else if(key.equals("bolCode")){
	            		
	            		pd.put("LADING_BILL_CODE", idField);	
	            	}else if(key.equals("thirdPlace")){
	            		
	            		pd.put("THIRD_NAME", idField);	
	            	}else if(key.equals("harbourPkgs")){//货物件数
	            		
	            		pd.put("GOODS_NUM", idField);	
	            	}else if(key.equals("goodsPkgs")){
	            		pd.put("GOODS_NUM", idField);	
	            	}
	            	else if(key.equals("consigneeMscCode")){
	            		
	            		pd.put("CONSIGNEE_MSC_CODE", idField);	
	            	}else if(key.equals("enquiryNo")){//报价编号
	            		
	            		pd.put("OFFER_NUM", idField);	
	            	}else if(key.equals("trailerPrice")){
	            		
	            	
	            	}else if(key.equals("harbourPackage")){//货物单位
	            		pd.put("GOODS_UNIT", idField);	
	            	}else if(key.equals("forwarder_man")){//货代客服
	            		pd.put("FORWARDER_CUSTOMER_SERVICE", idField);	
	            	}else if(key.equals("unloadHarbour")){//江船卸区
	            		pd.put("RIVER_UNLOAD_ID", idField);
	            		pd.put("RIVER_UNLOAD", textField);
	            	}else if(key.equals("secondSalesManDep")){//第二销售人员所属部门
	            		pd.put("SEC_SALE_STAFF_DEPART_ID", idField);
	            		pd.put("SEC_SALE_STAFF_DEPART", textField);
	            	}else if(key.equals("emptyweightbox")){
	            		pd.put("EMPTY_WEIGHT_BOX", idField);
	            	}else if(key.equals("subsupplier")){//分供方
	            		pd.put("SUB_SUPPLIER_ID", idField);
	            		pd.put("SUB_SUPPLIER", textField);
	            	}else if(key.equals("price_source")){//价格来源
	            		pd.put("PRICE_SOURCE", idField);	            		
	            	}
 	           
	            }
	           
	         
	         
	        } 
	          int packtype=-1;
	            if(pd.get("IS_FACTORYPACKING")!=null && pd.get("IS_FACTORYPACKING")=="0")
	            {
	            	packtype=0;
	            }
	           if(pd.get("IS_HARBOURPACKING")!=null && pd.get("IS_HARBOURPACKING")=="1")
              {
            	  if(packtype==0){
            		  packtype=2;
            	  }else if(packtype==-1)
            	  {
            		  packtype=1;
            	  }
            		  
              }
	          pd.put("BOX_LOAD_TYPE", packtype);
	          
	        String USERNAME = Jurisdiction.getUsername();//当前登录的用户名        	
	        //System.out.println("a");
			JSONObject obj = new JSONObject();
			
			String flag = "";
			Map<String,Object> mp= (Map<String,Object>)consignInputService.queryBillCode(pd);
		    if(mp!=null && (int)mp.get("cnt")>0){
		    	 flag = consignInputService.consignUpdate(pd);		
		    }else{
		    	flag = consignInputService.consignAdd(pd);	
		    }
		  
			
			if("1".equals(flag)){//托单保存成功将托单编号写入流水号表中
				Map<String,String> parma=new HashMap<String,String>();
				parma.put("businessType",billCode.substring(6,8));
				parma.put("billCode", billCode);
				consignInputService.consignFlowNumUpdate(parma);
			}
			if("1".equals(flag) && "2".equals(isTrailer))//委托拖车
        	{
				Map<String, String> map =new HashMap<String,String>();
				map.put("billCode", billCode);
				//trailerList.add(map);
				int trailerNum = consignInputService.getTrailerNum(map);
				if(trailerNum>0){
					consignInputService.deleteTrailer(map);
				}
				if(trailerList.size()>0)
				System.out.println(trailerList);
        		consignInputService.trailerInsert(trailerList);
        	}
			if(!boxList.isEmpty()){
				
				consignInputService.boxtypeNumInsert(boxList);
			}
			JSONArray json = new JSONArray();
            if("1".equals(flag))
            {
            	json.add("SUCCESS");
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
    	  }catch(Exception ex){
    		ex.printStackTrace();
    	  }
	    }
	    @RequestMapping(value="/getUserId")
	    public void getUserId(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	    	
			Object	o = consignInputService.getUserId(page);
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(o.toString());	 				
			response.getWriter().flush();
	    }
	    @RequestMapping(value="/getTradeInfo")
	    public void getTradeInfo(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	        PageData pd = new PageData();
	        pd = this.getPageData();
			JSONObject obj = new JSONObject();
			page.setPd(pd);
			List<PageData>	tradeinfoList = consignInputService.getTradeInfo(page);
			JSONArray json = new JSONArray();
            for(PageData p : tradeinfoList){
                JSONObject jo = new JSONObject();
                
                jo.put("salesMan", p.get("SALER_ID"));      
                jo.put("salesManName", p.get("SALER_NAME"));      
                jo.put("departmentId", p.get("DEPARTMENT_ID"));      
                jo.put("salesManDep", p.get("DEPARTMENT"));      
                jo.put("companyCode", p.get("REGION_ID"));      
                jo.put("salesManAgent", p.get("REGION"));  
                
                jo.put("salesMan2", p.get("SEC_SALER_ID"));      
                jo.put("secondSalesMan", p.get("SEC_SALER_NAME")); 
                jo.put("secondDep", p.get("SEC_SALE_STAFF_DEPART_ID"));    
                jo.put("secondSalesManDep", p.get("SEC_SALE_STAFF_DEPART")); 
                jo.put("secondCompany", p.get("SEC_SALE_STAFF_REGION_ID"));
                jo.put("secondSalesAgent", p.get("SEC_SALE_STAFF_REGION")); 
                
                
                jo.put("HBL_SEND_TYPE", p.get("HBL_SEND_TYPE"));      
                jo.put("isTaoyue", p.get("ISSET_ABOUT"));    
                jo.put("agencyManId", p.get("SHIPPER_ID"));      
                jo.put("agencyMan", p.get("SHIPPER_NAME"));      
                jo.put("agencyContactId", p.get("CONSIGNOR_ID"));        
                jo.put("agencyContact", p.get("CONSIGNOR_NAME"));      
                jo.put("agencySelfNo", p.get("SHIPPER_NUM"));      
                jo.put("contact", p.get("SHIPPER_CONTACT"));      
                jo.put("payWay", p.get("PAYMENT_METHOD"));      
                jo.put("clientType", p.get("CLENT_TYPE"));      
                jo.put("contactInfo", p.get("SHIPPER_CONTACT_WAY"));      
                jo.put("boxMaster_id", p.get("CONTAINER_OWNER_KEY"));      
                jo.put("box_master", p.get("CONTAINER_OWNER"));      
                jo.put("invoiceNo", p.get("INVOICE_NUM"));      
                jo.put("GOODS_TYPE_CODE", p.get("GOODS_TYPE_CODE"));      
                jo.put("supplyOfGoods", p.get("GOODS_TYPE_NAME"));      
                jo.put("forwarder_man", p.get("FORWARDER_CUSTOMER_SERVICE"));      
                jo.put("shipper", p.get("SEND_CONSIGNOR"));      
                jo.put("consignee", p.get("CONSIGNEE"));      
                jo.put("noticeMan", p.get("NOTIFIER"));      
                jo.put("goodsSign", p.get("SHIPPING_MARK "));      
                jo.put("boxMasterRemark", p.get("SHIPPING_COMPANY_BOOK_NOTE"));      
                jo.put("goodsEnglishName", p.get("GOODS_DESCRIPTION"));      
                jo.put("tradeMode", p.get("TRADE_METHOD"));      
                jo.put("partialFlag", p.get("IS_BATCH"));      
                jo.put("changeShipFlag", p.get("IS_TRANSSHIP"));      
                jo.put("DESTINATION_COUNTRY_ID", p.get("DESTINATION_COUNTRY_ID"));      
                jo.put("stopCountry", p.get("DESTINATION_COUNTRY"));      
                jo.put("goodsSource", p.get("TERRITORY_GOODS_SUPPLY"));      
                jo.put("goodsChineseName", p.get("CHINESE_NAME"));      
                jo.put("hsCode", p.get("HS_CODE"));      
                jo.put("IS_WOODEN_PACK", p.get("IS_WOODEN_PACK"));   
                jo.put("harbourPkgs", p.get("HARBOURPKGS")); 
                jo.put("harbourPackage", p.get("HARBOURPACKAGE"));
                jo.put("harbourKg", p.get("HARBOURKG")); 
                jo.put("harbourVolume", p.get("HARBOURVOLUME"));
                jo.put("goodsPkgs", p.get("GOODS_NUM")); 
                jo.put("goodsPackage", p.get("UNIT"));     
                jo.put("goodsWeight", p.get("GOODS_GROSS_WEIGHT"));      
                jo.put("goodsMeasurment", p.get("VOLUME"));      
                jo.put("loadDate", p.get("ESTIMATE_RIVER_BOAT_TIME"));      
                jo.put("shipLine", p.get("APPOINT_SHIP_ROUTE"));      
                jo.put("putBoxDate", p.get("ESTIMATE_TIME"));      
                jo.put("pickBoxDate", p.get("ESTIMATE_EXTRACT_BOX_TIME"));      
                jo.put("shippingDate", p.get("APPOINT_ESTIMATE_SHIP_TIME"));      
                jo.put("preSeashipStopDate", p.get("APPOINT_ESTIMATE_SHIP_EXPIRE_TIME")); 
                jo.put("orderBoxDate", p.get("APPOINT_PUT_CONTAINER_TIME")); 
                
                jo.put("BILL_TYPE_ID", p.get("BILL_TYPE_ID"));  
                jo.put("bolType_id", p.get("BILL_TYPE_ID"));
                jo.put("bolType", p.get("BILL_TYPE"));      
                jo.put("BOX_TYPE_CONFIRM", p.get("BOX_TYPE_CONFIRM"));      
                jo.put("specifiedBox", p.get("IS_APPOINT_USERBOX"));      
                jo.put("CLIENT_FREE_HEAP_TIME", p.get("CLIENT_FREE_HEAP_TIME"));      
                jo.put("goodsType", p.get("GOODS_TYPE"));      
                jo.put("priceSource", p.get("PRICE_SOURCE"));      
                jo.put("enquiryNo", p.get("OFFER_NUM"));      
                jo.put("INCONE_REMARK", p.get("INCONE_REMARK"));      
                jo.put("yueHao", p.get("BOAT_COMPANY_ADVANCE_NUM"));      
                jo.put("priceAmount", p.get("BOAT_COMPANY_BOOK_PRICE"));      
                jo.put("price_start_date", p.get("PRICE_START_TIME"));      
                jo.put("price_end_date", p.get("PRICE_STOP_TIME"));      
                jo.put("TRANSPORT_CLAUSE_ID", p.get("TRANSPORT_CLAUSE_ID"));      
                jo.put("transportItem", p.get("TRANSPORT_CLAUSE"));      
                jo.put("FREIGHT_CLAUS_ID", p.get("FREIGHT_CLAUS_ID"));      
                jo.put("carriageType", p.get("FREIGHT_CLAUS"));      
                jo.put("feeItem", p.get("OTHER_FREIGHT_CLAUSE"));      
                jo.put("isBuyClass", p.get("IS_BUY_CLASS"));      
                jo.put("CUS_MOD_ID", p.get("CUS_MOD_ID")); 
                jo.put("gateType", p.get("CUS_MOD")); 
                jo.put("CUS_BRO_ID", p.get("CUS_BRO_ID"));
                jo.put("gateUnit", p.get("CUS_BRO"));                      
                jo.put("gateNum", p.get("CUSTOMS_NUM"));      
                jo.put("cNum", p.get("FEW"));      
                jo.put("sjNum", p.get("COMMODITY_INSPECTION_NUM"));      
                jo.put("customDistrict", p.get("DECLARATION_CUMTOMS"));      
                jo.put("gateRemark", p.get("DECLARE_CUSTOMS_REQUIRE"));      
                jo.put("isTrailer", p.get("IS_ARRANGE_TRAILER"));      
                jo.put("TRAILER_ID", p.get("TRAILER_ID"));      
                jo.put("TRAILER", p.get("TRAILER"));      
                jo.put("insurance", p.get("AGENCY_INSURANCE"));      
                jo.put("bxmc", p.get("INSURANCE_NAME"));      
                jo.put("bxje", p.get("INSURANCE_AMOUNT"));      
                jo.put("bxbl", p.get("INSURANCE_RATE"));      
                jo.put("bz", p.get("INSURANCE_REMARK"));      
                jo.put("ENCASEMENT_METHOD", p.get("ENCASEMENT_METHOD"));      
                jo.put("isStifling", p.get("IS_FUMIGATION"));      
                jo.put("remarks", p.get("OPERATION_REMARK"));      
                jo.put("BUSINESS_TYPE_ID", p.get("BUSINESS_TYPE_ID"));      
                jo.put("BUSINESS_TYPE", p.get("BUSINESS_TYPE"));
                
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                String orderDate = null;
                if(p.get("ENTRUST_TIME")!=null){
                	orderDate = sdf.format(p.get("ENTRUST_TIME"));
                }
                jo.put("orderDate", orderDate);      
                jo.put("LADING_BILL_CODE",orderDate);      
                jo.put("typeShipping", p.get("TRANSPORT_METHOD"));      
                jo.put("PORT_LOADING_ID", p.get("PORT_LOADING_ID"));      
                jo.put("portOfLoading", p.get("PORT_LOADING"));      
                jo.put("PORT_DISCHARGE_ID", p.get("PORT_DISCHARGE_ID"));      
                jo.put("portOfDischarge", p.get("PORT_DISCHARGE"));      
                jo.put("PLACE_DELIVERY_ID", p.get("PLACE_DELIVERY_ID"));      
                jo.put("placeOfDelivery", p.get("PLACE_DELIVERY"));  
                jo.put("stop_harbour", p.get("PLACE_DELIVERY"));
                jo.put("SEA_RECEIPT_ID", p.get("SEA_RECEIPT_ID"));      
                jo.put("placeOfReceipt", p.get("SEA_RECEIPT"));      
                jo.put("SEA_LOAD_ID", p.get("SEA_LOAD_ID"));      
                jo.put("SEA_LOAD", p.get("SEA_LOAD"));      
                jo.put("SEA_UNLOAD_ID", p.get("SEA_UNLOAD_ID"));      
                jo.put("seaShipStop", p.get("SEA_UNLOAD"));      
                jo.put("RIVER_DELIVERY_ID", p.get("RIVER_DELIVERY_ID"));      
                jo.put("RIVER_DELIVERY", p.get("RIVER_DELIVERY"));      
                jo.put("RIVER_PORT_ID", p.get("RIVER_PORT_ID"));      
                jo.put("riverLoad", p.get("RIVER_PORT"));      
                jo.put("RIVER_UNLOAD_ID", p.get("RIVER_UNLOAD_ID"));      
                jo.put("unloadHarbour", p.get("RIVER_UNLOAD"));      
                jo.put("RIVER_LOAD_ID", p.get("RIVER_LOAD_ID"));      
                jo.put("loadHarbour", p.get("RIVER_LOAD"));      
                jo.put("CUSTOMS_CODE", p.get("CUSTOMS_CODE"));      
                jo.put("RESERVE_MATCH_BOX_OWNER", p.get("RESERVE_MATCH_BOX_OWNER"));      
                jo.put("CONTAINERNO", p.get("CONTAINERNO"));      
                jo.put("IS_LCL", p.get("IS_LCL"));      
                jo.put("IS_ENPTY_BOX", p.get("IS_ENPTY_BOX"));      
                jo.put("IS_TRANSSIP", p.get("IS_TRANSSIP"));      
                jo.put("IS_SPECIAL_BOX", p.get("IS_SPECIAL_BOX"));      
                //jo.put("goodsPackage", p.get("GOODS_UNIT"));  
                //jo.put("goodsPackage", p.get("UNIT")); 
                jo.put("priceRemarks", p.get("PRICE_REMARK"));      
                jo.put("RESERVE_NUM", p.get("RESERVE_NUM"));      
                jo.put("TRADE_TYPE_ID", p.get("TRADE_TYPE_ID"));      
                jo.put("TRADE_TYPE", p.get("TRADE_TYPE"));      
                jo.put("DEDUCT_CUC", p.get("DEDUCT_CUC"));      
                jo.put("CONSIGNEE_MSC_CODE", p.get("CONSIGNEE_MSC_CODE"));      
                jo.put("CONTAINER_NO", p.get("CONTAINER_NO"));      
                jo.put("thirdPlace", p.get("THIRD_NAME"));
                jo.put("boxType", p.get("BOX_TYPE_CONFIRM"));    
                jo.put("boxTypeFactory", p.get("FACTORY_CONTAINER_TYPE_NUM"));      
                jo.put("boxTypeHarbor", p.get("PORT_CONTAINER_TYPE_NUM"));      
                jo.put("PORT_LOAD_REQUIREMENTS", p.get("PORT_LOAD_REQUIREMENTS"));      
                jo.put("LOAD_CONTAINER_TIME", p.get("LOAD_CONTAINER_TIME"));      
                jo.put("APPOINT_PUT_CONTAINER_TIME", p.get("APPOINT_PUT_CONTAINER_TIME"));      
                jo.put("UNIT", p.get("UNIT"));      
                jo.put("FACTORY_SPLIT_TYPE_NUM", p.get("FACTORY_SPLIT_TYPE_NUM"));      
                jo.put("PORT_SPLIT_TYPE_NUM", p.get("PORT_SPLIT_TYPE_NUM"));      
                jo.put("PORT_SPLIT_REQUIREMENTS", p.get("PORT_SPLIT_REQUIREMENTS"));      
                jo.put("TWENTY_GP", p.get("TWENTY_GP"));      
                jo.put("FORTY_GP", p.get("FORTY_GP"));      
                jo.put("bigBoxh", p.get("FORTY_HC"));
                jo.put("FORTY_FIVE", p.get("FORTY_FIVE")); 
                jo.put("SPECIAL_CONTAINER", p.get("SPECIAL_CONTAINER"));      
                jo.put("TEU", p.get("TEU"));      
                jo.put("BILL_STATUS", p.get("BILL_STATUS"));      
                jo.put("BILL_INPUTER", p.get("BILL_INPUTER"));      
                jo.put("CREATE_TIME", p.get("CREATE_TIME"));      
                jo.put("SHIP_COMPANY_ID", p.get("SHIP_COMPANY_ID"));      
                jo.put("SHIP_COMPANY", p.get("SHIP_COMPANY"));      
                jo.put("SHIP_VOYAGE_NAME", p.get("SHIP_VOYAGE_NAME"));      
                jo.put("SHIP_VOYAGE_CODE", p.get("SHIP_VOYAGE_CODE"));      
                jo.put("SHIP_REGION_ID", p.get("SHIP_REGION_ID"));      
                jo.put("SHIP_REGION", p.get("SHIP_REGION"));      
                jo.put("SHIP_NAME_ID", p.get("SHIP_NAME_ID"));      
                jo.put("SHIP_NAME", p.get("SHIP_NAME"));      
                jo.put("SHIP_ETD", p.get("SHIP_ETD"));      
                jo.put("SHIP_ATD", p.get("SHIP_ATD"));      
                jo.put("SHIP_ETA", p.get("SHIP_ETA"));      
                jo.put("SHIP_ATA", p.get("SHIP_ATA"));      
                jo.put("BOAT_NAME_ID", p.get("BOAT_NAME_ID"));      
                jo.put("BOAT_NAME", p.get("BOAT_NAME"));      
                jo.put("BOAT_VOYAGE_NAME", p.get("BOAT_VOYAGE_NAME"));      
                jo.put("BOAT_VOYAGE_CODE", p.get("BOAT_VOYAGE_CODE"));      
                jo.put("BOAT_ETD", p.get("BOAT_ETD"));      
                jo.put("BOAT_ATD", p.get("BOAT_ATD"));      
                jo.put("BOAT_ETA", p.get("BOAT_ETA"));      
                jo.put("BOAT_ATA", p.get("BOAT_ATA"));      
                jo.put("CONTAINER_TYPE_NUM", p.get("CONTAINER_TYPE_NUM"));      
                jo.put("MATCH_LOAD_REMARK", p.get("MATCH_LOAD_REMARK"));      
                jo.put("BOAT_PLAN_SAIL_TIME", p.get("BOAT_PLAN_SAIL_TIME"));      
                jo.put("WEIGHT_BOX_TIME", p.get("WEIGHT_BOX_TIME"));      
                jo.put("IS_CUSTOM_INFO_ARRIVE", p.get("IS_CUSTOM_INFO_ARRIVE"));      
                jo.put("PACK_TYPE", p.get("PACK_TYPE"));      
                jo.put("SINGLE_TYPE_ID", p.get("SINGLE_TYPE_ID"));      
                jo.put("SINGLE_TYPE", p.get("SINGLE_TYPE"));      
                jo.put("BILL_FLOW_ID", p.get("BILL_FLOW_ID"));      
                jo.put("BILL_FLOW", p.get("BILL_FLOW"));
                String supplier ="";
                if(p.get("SUB_SUPPLIER")!=null) supplier=p.get("SUB_SUPPLIER").toString().trim();
                jo.put("subsupplier",supplier);
                jo.put("emptyweightbox", p.get("EMPTY_WEIGHT_BOX"));
                jo.put("loadType0", p.get("IS_FACTORYPACKING"));
                jo.put("loadType1",  p.get("IS_HARBOURPACKING"));                
                jo.put("boxLoadType",  p.get("BOX_LOAD_TYPE")); 
                jo.put("hasIPPC",  p.get("HAS_IPPC"));      
                
                json.add(jo);
            }
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(json.toString());	 				
			response.getWriter().flush();
	    }
	    @RequestMapping(value="/consignEdit")
		@ResponseBody
		public void consignEdit(HttpServletResponse response)throws Exception{
			
			
		  	try{
	    		
		        PageData pd =  new PageData();
		        pd=this.getPageData();
		        String billCode =pd.getString("bcode");
		        pd.put("billCode", billCode);
		        String isTrailer="";//0默认，1自拖车2委托拖车
		      
		        Object [] arr= pd.entrySet().toArray();
		        List<Map<String,String>> trailerList= new ArrayList<Map<String, String>>();
		        List<Map<String,String>> trailerList1= new ArrayList<Map<String, String>>();
		        List<Map<String,String>> boxList= new ArrayList<Map<String, String>>();
		        
		        String oog="";
		        String teu="";
		        
		        for(int i=0;i<arr.length;i++)
		        {
		        	Map<String,Object> map = Tools.objectToMap(arr[i]);
		           Object key = map.get("key");
		           String val =map.get("value").toString();
		           String idField = "";
		           String textField = "";
		            getTrailerList(trailerList,key,val,billCode);
		            if(key.equals("aa")) getBoxList(boxList,key,val,pd.getString("boxType"),pd.getString("billCode"));
		           
		            if(!"".equals(val) && val.indexOf("!@")<0)
		            {
		            	String [] el = val.split("@");
		            	
		   	             if(el.length==2)
		   	             {
		   	            	idField = el[0];
		   	                textField = el[1];
		   	             }else{
		   	            	idField = el[0];
		   	             }
		   	            if(key.equals("is_trailer"))
			           	{   isTrailer=idField;
			           		pd.put("IS_ARRANGE_TRAILER", idField);
			           	}else if(key.equals("salesManName"))
		            	{
		            		pd.put("SALER_ID", idField);
		            		pd.put("SALER_NAME", textField);
		            		
		            	}else if(key.equals("sales_man_dep"))
		            	{
		            		pd.put("DEPARTMENT_ID", idField);
		            		pd.put("DEPARTMENT", textField);
		            	}else if(key.equals("agency_man"))//托运人
		            	{
		            		if(!val.toString().contains("@")){
		            			textField = consignInputService.getAgencyManNameById(idField);
		            		}
		            		pd.put("SHIPPER_ID", idField);
		            		pd.put("SHIPPER_NAME", textField);
		            		
		            	}else if(key.equals("isHBL"))
		            	{
		            		pd.put("HBL_SEND_TYPE_ID", idField);
		            		pd.put("HBL_SEND_TYPE", textField);
		            	
		            	}else if(key.equals("isTaoyue"))//y
		            	{
		            		if("y".equals(idField))
		            		{
		            			pd.put("ISSET_ABOUT", 1);
		            		}else
		            		{
		            			pd.put("ISSET_ABOUT", 0);
		            		}
		            		
		            	}else if(key.equals("agency_contact"))
		            	{
		            		pd.put("CONSIGNOR_ID", idField);
		            		pd.put("CONSIGNOR_NAME", textField);
		            		
		            	}else if(key.equals("agency_self_no"))//托运人自编号
		            	{
		            		pd.put("SHIPPER_NUM", idField);
		            	}else if(key.equals("contact"))//托运人联系人
		            	{
		            		pd.put("SHIPPER_CONTACT", idField);	            		
		            		
		            	}else if(key.equals("pay_way"))
		            	{
		            		pd.put("PAYMENT_METHOD", idField);
		            	}else if(key.equals("client_type"))
		            	{
		            		pd.put("CLENT_TYPE", idField);
		            	}else if(key.equals("latestDateOfShipment"))
		            	{
		   	             	pd.put("LASTEST_DELIVERY",idField);						
		            	}else if(key.equals("contact_info"))
		            	{	            		
		            		pd.put("SHIPPER_CONTACT_WAY", idField);//联系方式 
		            	}else if(key.equals("placeOfDelivery"))
		            	{
		            		if(!val.contains("@")){
		            			textField = consignInputService.getPlaceOfDeliveryNameById(idField);
		            		}
		            		pd.put("PLACE_DELIVERY_ID", idField);
		            		pd.put("PLACE_DELIVERY", textField);
		            	}else if(key.equals("box_master"))//箱主
		            	{
		            		if(!val.toString().contains("@")){
		            			textField = consignInputService.getBoxMasterNameById(idField);
		            		}
		                    pd.put("CONTAINER_OWNER_KEY", idField);
		            		pd.put("CONTAINER_OWNER", textField);
		            	}else if(key.equals("invoice_no"))
		            	{
		            		pd.put("INVOICE_NUM", idField);
		            	}else if(key.equals("supply_of_goods"))
		            	{
		            		pd.put("GOODS_TYPE_CODE", idField);
			            	pd.put("GOODS_TYPE_NAME", textField);
		            		
		            	}else if(key.equals("forwarder_man"))
		            	{
		            		pd.put("FORWARDER_CUSTOMER_SERVICE", idField);
		            	}else if(key.equals("shipper"))//
		            	{	            		
		            		pd.put("SEND_CONSIGNOR", idField);
		            	}else if(key.equals("box_master_remark"))
		            	{
		            		pd.put("SHIPPING_COMPANY_BOOK_NOTE", idField);
		            		
		            	}else if(key.equals("consignee"))
		            	{
		            		pd.put("CONSIGNEE", idField);
		            	}else if(key.equals("goods_sign"))
		            	{
		            		pd.put("SHIPPING_MARK", idField);
		            	}else if(key.equals("notice_man"))
		            	{
		            		pd.put("NOTIFIER", idField);
		            	}else if(key.equals("goods_english_name"))
		            	{
		            		pd.put("GOODS_DESCRIPTION", idField);
		            	}else if(key.equals("trade_mode"))
		            	{
		            		pd.put("TRADE_METHOD", idField);
		            	}else if(key.equals("partial_flag"))//可否分批
		            	{
		            		pd.put("IS_BATCH", idField);
		            	}else if(key.equals("change_ship_flag"))//可否转船
		            	{
		            		pd.put("IS_TRANSSHIP", idField);
		            	}else if(key.equals("port_of_loading"))
		            	{
		            		if(!val.contains("@")){
		            			textField = consignInputService.getPortOfDischargeNameById(idField);
		            		}
		            		pd.put("PORT_LOADING_ID", idField);
		            		pd.put("PORT_LOADING", textField);
		            	}else if(key.equals("portOfDischarge"))//目的港
		            	{
		            		if(!val.toString().contains("@")){
		            			textField = consignInputService.getPortOfDischargeNameById(idField);
		            		}
		            		pd.put("PORT_DISCHARGE_ID", idField);
		            		pd.put("PORT_DISCHARGE", textField);
		            	}else if(key.equals("stop_harbour"))
		            	{
		            		if(!val.toString().contains("@")){
		            			textField = consignInputService.getStopHarbourNameById(idField);
		            		}
		            		pd.put("PLACE_DELIVERY_ID", idField);
		            		pd.put("PLACE_DELIVERY", textField);
		            	}else if(key.equals("load_harbour"))
		            	{
		            		pd.put("RIVER_LOAD_ID", idField);
		            		pd.put("RIVER_LOAD", textField);
		            	}else if(key.equals("stop_country"))//目的国家
		            	{
		            		pd.put("DESTINATION_COUNTRY_ID", idField);
		            		pd.put("DESTINATION_COUNTRY", textField);
		            	}else if(key.equals("goods_source"))//境内货源地
		            	{
		            		pd.put("TERRITORY_GOODS_SUPPLY_ID", idField);
		            		pd.put("TERRITORY_GOODS_SUPPLY", textField);
		            	}else if(key.equals("goods_chinese_name"))//中文品名
		            	{
		            		pd.put("CHINESE_NAME", idField);
		            	}else if(key.equals("hs_code"))
		            	{
		            		pd.put("HS_CODE", idField);
		            	}else if(key.equals("goods_measurment"))//托单货物体积
		            	{
		            		pd.put("VOLUME", idField);
		            	}else if(key.equals("goodsPkgs"))//货物件数
		            	{
		            		pd.put("GOODS_NUM", idField);
		            	}else if(key.equals("goods_package"))
		            	{
		            		pd.put("UNIT", idField);
		            	
		            	}else if(key.equals("goods_weight"))
		            	{
		            		pd.put("GOODS_GROSS_WEIGHT", idField);
		            	}else if(key.equals("load_date"))
		            	{
		            		pd.put("ESTIMATE_RIVER_BOAT_TIME",idField);//预计江船装船时间
		            	}else if(key.equals("ship_line"))
		            	{
		            		pd.put("APPOINT_SHIP_ROUTE", idField);//指定海船航线
		            	}else if(key.equals("put_box_date"))//放箱时间
		            	{
		            		pd.put("ESTIMATE_TIME", idField);
		            		
		            	}else if(key.equals("pick_box_date"))//预约摆箱时间
		            	{
		            		pd.put("ESTIMATE_EXTRACT_BOX_TIME", idField);
		            	}else if(key.equals("shipping_date"))//指定预计海船期
		            	{
		            		pd.put("APPOINT_ESTIMATE_SHIP_TIME", idField);
		            	}else if(key.equals("pre_seaship_stop_date"))//指定预计海船到港期
		            	{
		            		pd.put("APPOINT_ESTIMATE_SHIP_EXPIRE_TIME", idField);
		            	}else if(key.equals("bol_type"))//提单类型
		            	{
		            		if(!val.contains("@")){
		            			if(pd.get("bolType_Id")!=null){
		            				textField = consignInputService.getBolTypeNameById(pd.getString("bolType_Id"));
		            				idField = pd.getString("bolType_Id");
		            			}
		            		}
		            		pd.put("BILL_TYPE_ID", idField);
		            		pd.put("BILL_TYPE", textField);
		            	
		            	}else if(key.equals("box_type"))//箱型确定
		            	{
		            		pd.put("BOX_TYPE_CONFIRM", idField);
		            	}else if(key.equals("specified_box"))
		            	{
		            		pd.put("IS_APPOINT_USERBOX", idField);//0否，1是，2自备箱
		            	}else if(key.equals("box_no"))//箱号
		            	{
		            		pd.put("CONTAINER_NO", idField);
		            	}else if(key.equals("freeDayRemark"))
		            	{
		            		pd.put("CLIENT_FREE_HEAP_TIME", idField);//客户免堆期
		            	}else if(key.equals("goodsType"))//货物种类
		            	{
		            		pd.put("GOODS_TYPE", idField);
		            	}else if(key.equals("price_source")) //0 销售拿价 1  自拿价 2市场报价  
		            	{
		            		pd.put("PRICE_SOURCE", idField);
		            	}else if(key.equals("enquiry_no"))//报价编号
		            	{
		            		pd.put("OFFER_NUM", idField);
		            	}else if(key.equals("price_remarks"))//价格备注
		            	{
		            		pd.put("PRICE_REMARK", idField);
		            	}else if(key.equals("yue_hao"))//船公司约号
		            	{
		            		pd.put("BOAT_COMPANY_ADVANCE_NUM", idField);
		            	}else if(key.equals("price_amount"))//船公司订舱价格
		            	{
		            		pd.put("BOAT_COMPANY_BOOK_PRICE", idField);
		            	}else if(key.equals("price_start_date"))//价格开始时间
		            	{
		            		pd.put("PRICE_START_TIME", idField);
		            	}else if(key.equals("price_end_date"))//价格结束时间
		            	{
		            		pd.put("PRICE_STOP_TIME", idField);
		            	}else if(key.equals("transport_item"))//运输条款
		            	{
		            		if(!val.toString().contains("@")){
		            			textField = consignInputService.getTransportItemNameById(idField);
		            		}
		            		pd.put("TRANSPORT_CLAUSE_ID", idField);
		            		pd.put("TRANSPORT_CLAUSE", textField);
		            		
		            		String sc= textField.split("--")[0];
		            		String ec=textField.split("--")[1];
		            		pd.put("START_TRANSPORT_CLAUSE", sc);
		            		pd.put("END_TRANSPORT_CLAUSE",ec);
		            		
		            	}else if(key.equals("carriage_type"))//运费条款
		            	{
		            		pd.put("FREIGHT_CLAUS", idField);	            		
		            	}else if(key.equals("fee_item"))//其他运费条款
		            	{
		            		pd.put("OTHER_FREIGHT_CLAUSE", idField);
		            	}else if(key.equals("isBuyClass"))//是否买舱
		            	{
		            		pd.put("IS_BUY_CLASS", idField);
		            	}else if(key.equals("gate_type"))
		            	{
		         	     	//pd.put("CUS_MOD_ID", idField);
		            		pd.put("CUS_MOD", idField);
		            	}else if(key.equals("gate_unit"))
		            	{
		            		if(!val.contains("@")){
		            			textField = consignInputService.getGateUnitNameById(idField);
		            		}
		            		pd.put("CUS_BRO_ID", idField);
		            		pd.put("CUS_BRO", textField);
		            	}else if(key.equals("gate_num"))
		            	{
		            		pd.put("CUSTOMS_NUM", idField);
		            	}else if(key.equals("cNum")){
		            		pd.put("FEW", idField);
		            	}else if(key.equals("sj_num"))
		            	{
		            		pd.put("COMMODITY_INSPECTION_NUM", idField);
		            	}else if(key.equals("custom_district"))//申请地海关
		            	{
		            		pd.put("DECLARATION_CUMTOMS", idField);
		            	}else if(key.equals("gateRemark"))
		            	{
		            		pd.put("DECLARE_CUSTOMS_REQUIRE", idField);
		            	}else if(key.equals("insurance"))//办理保险
		            	{
		            		pd.put("AGENCY_INSURANCE", idField);
		            	}else if(key.equals("bxmc"))
		            	{
		            		pd.put("INSURANCE_NAME", idField);//保险名称
		            	}else if(key.equals("bxje"))
		            	{
		            		pd.put("INSURANCE_AMOUNT", idField);//保险金额
		            	}else if(key.equals("bxbl"))
		            	{
		            		pd.put("INSURANCE_RATE", idField);
		            	}else if(key.equals("bz"))//保险备注
		            	{
		            		pd.put("INSURANCE_REMARK", idField);
		            	}else if(key.equals("loadType0"))//厂装
		            	{
		            		pd.put("IS_FACTORYPACKING", idField);
		            	}else if(key.equals("loadType1"))//港装
		            	{
		            		pd.put("IS_HARBOURPACKING", idField);
		            	}else if(key.equals("is_stifling"))//y
		            	{
		            		if("y".equals(idField)){
		            		pd.put("IS_FUMIGATION", 1);
		            		}else{
		            		  pd.put("IS_FUMIGATION", 0);
		            		}
		            	}
		            	else if(key.equals("remarks")){
		            		pd.put("OPERATION_REMARK", idField);
		            	}else if(key.equals("second_sales_agent"))
		            	{
		            		pd.put("SEC_SALE_STAFF_REGION_ID", idField);
		            		pd.put("SEC_SALE_STAFF_REGION", textField);
		            	}else if(key.equals("cNum")){	            		
		            		pd.put("FEW", idField);
		            	}else if(key.equals("harbour_volume")){	            		
		            		pd.put("HARBOURVOLUME", idField);
		            	}else if(key.equals("h_box_type")){//指定用箱箱型
		            		pd.put("APPOINT_USERBOX_TYPE", idField);
		            	}else if(key.equals("startInputTime")){
		            		
		            		pd.put("START_INPUT_TIME", idField);	
		            	}else if(key.equals("endInputTime")){//object
		            		pd.put("END_INPUT_TIME", idField);	
		            	}else if(key.equals("dangerous_type")){//危险品类别
		            		pd.put("DANGEROUSTYPE", idField);
		            	}//else if(key.equals("tradeFlag")){
		            		
//		            	}else if(key.equals("searchNoticeMan")){
//		            		
//		            	}
						else if (key.equals("stopHarbour")){
		            		pd.put("RIVER_DELIVERY_ID",idField);
		            		pd.put("RIVER_DELIVERY",textField);
						}
		   	            else if(key.equals("box_type_factory")){//厂装箱型箱量
		   	            	
		   	            	pd.put("FACTORY_CONTAINER_TYPE_NUM", idField);
		            	}else if(key.equals("box_type_harbor")){//港装港装箱型箱量
		            		pd.put("PORT_CONTAINER_TYPE_NUM", idField);
		            	}else if(key.equals("sales_man_agent")){
		            		pd.put("REGION_ID", idField);
		            		pd.put("REGION", textField);
		            	}else if(key.equals("harbour_kg")){//港装货物毛重
		            		pd.put("HARBOURKG", idField);
		            	}else if(key.equals("trailerContact")){//拖车联系人
		            		
		            		pd.put("CONTACT_PERSON", idField);
		            	}else if(key.equals("harbour_date")){//装箱时间
		            		pd.put("LOAD_CONTAINER_TIME",idField);
		            	}else if(key.equals("seaShipStop")){//海船卸区
		            		pd.put("SEA_UNLOAD_ID", idField);
		            		pd.put("SEA_UNLOAD", textField);
		            		
		            	}else if(key.equals("load_box_remark")){//港装要求	            		
		            		pd.put("PORT_LOAD_REQUIREMENTS", idField);
		            	}else if(key.equals("sealNo")){	            		
		            		pd.put("SEAL_NO", idField);
		            	}else if(key.equals("has_ippc")){//y木质包装是否有IPPC标准
		            		pd.put("HAS_IPPC", idField);
		            	}else if(key.equals("dangerous_name")){
		            		pd.put("DANGEROUS_NAME", idField);	            		
		            	}else if(key.equals("internal_code")){
		            		pd.put("INTERNAL_CODE", idField);	            		
		            	}else if(key.equals("placeOfReceipt")){
		            		
		            		pd.put("SEA_RECEIPT_ID", idField);
		            		pd.put("SEA_RECEIPT", textField);	    
		            	}else if(key.equals("second_sales_man")){//第二销售人员
		            		if(!val.toString().contains("@")){
		            			textField = consignInputService.getNameById(idField);
		            		}
		            		
		            		pd.put("SEC_SALER_ID", idField);
		            		pd.put("SEC_SALER_NAME", textField);	
		            	}else if(key.equals("cold_rem")){//冷藏温度	            		
		            		pd.put("COLD_REM", idField);
		            	}else if(key.equals("international_code")){	            		
		            		pd.put("INTERNATIONAL_CODE", idField);
		            	}else if(key.equals("trailerContactInfo")){	            		
		            		pd.put("CONTACT_INFO", idField);
		            	}
//		            	else if(key.equals("searchConsignee")){
//		            		
//		            	}
		            	else if(key.equals("gateUnit")){
		            		pd.put("CUS_BRO_ID", idField);
		            		pd.put("CUS_BRO", textField);	    
		            	}else if(key.equals("wooden_packing")){
		            		
		            		pd.put("IS_WOODEN_PACK", idField);
		            	}else if(key.equals("bigBox")){
		            		pd.put("FORTY_GP", idField);
		            	}else if(key.equals("smallBox")){
		            		pd.put("TWENTY_GP", idField);
		            	}else if(key.equals("bigbigBox")){
		            		pd.put("FORTY_FIVE", idField);
		            	}else if(key.equals("bigBoxH")){
		            		pd.put("FORTY_HP", idField);
		            	}else if(key.equals("teu")){
		            		pd.put("TEU", idField);
		            	}else if(key.equals("specialbox"))
		            	{
		            		pd.put("SPECIAL_CONTAINER", idField);
		            	}
//		            	else if(key.equals("salesManAgentShow")){
//		            		
//		            	}
		            	else if(key.equals("riverLoad")){
		            		
		            	}else if(key.equals("goods_type")){
		            		
		            		pd.put("GOODS_TYPE", idField);
		            		
		            	}else if(key.equals("returnBoxAddress")){//还箱地
		            		
		            		pd.put("RETCONTAINERADDR", idField);
		            	}else if(key.equals("order_date")){//?
		            		
		            		pd.put("ENTRUST_TIME", idField);
		            		
		            	}else if(key.equals("order_box_date")){//约摆箱时间
		            		pd.put("APPOINT_PUT_CONTAINER_TIME",idField);	            		
		            	}
//		            	else if(key.equals("searchShipper")){
//		            		
//		            	}
		            	else if(key.equals(" preSeashipStopDate")){//指定预计海船到港期
		            		
		            	  pd.put("APPOINT_ESTIMATE_SHIP_EXPIRE_TIME", idField);	         
		            	}else if(key.equals("typeShipping")){
		            		
		            		pd.put("TRANSPORT_METHOD", idField);	        
		            	}else if(key.equals("notifier_msc_code")){//通知人msccode
		            		pd.put("NOTIFY_MSC_CODE", idField);	
		            	}else if(key.equals("dangerous_level")){//危险品等级
		            		pd.put("DANGEROUS_LEVEL", idField);	
		            	}else if(key.equals("bolCode")){
		            		
		            		pd.put("LADING_BILL_CODE", idField);	
		            	}else if(key.equals("third_place")){
		            		
		            		pd.put("THIRD_NAME", idField);	
		            	}else if(key.equals("harbour_pkgs")){//货物件数
		            		
		            		pd.put("HARBOURPKGS", idField);
		            	}else if(key.equals("goods_pkgs")){
		            		pd.put("GOODS_NUM", idField);	
		            	}
		            	else if(key.equals("consignee_msc_code")){
		            		pd.put("CONSIGNEE_MSC_CODE", idField);	
		            	}else if(key.equals("enquiryNo")){//报价编号
		            		pd.put("OFFER_NUM", idField);	
		            	}else if(key.equals("trailerPrice")){
		            	}else if(key.equals("harbour_package")){//货物单位
		            		pd.put("HARBOURPACKAGE", idField);
		            	}else if(key.equals("forwarder_man")){//货代客服
		            		pd.put("FORWARDER_CUSTOMER_SERVICE", idField);	
		            	}else if(key.equals("unloadHarbour")){//江船卸区
		            		pd.put("RIVER_UNLOAD_ID", idField);
		            		pd.put("RIVER_UNLOAD", textField);
		            	}else if(key.equals("second_sales_man_dep")){//第二销售人员所属部门
		            		pd.put("SEC_SALE_STAFF_DEPART_ID", idField);
		            		pd.put("SEC_SALE_STAFF_DEPART", textField);
		            	}else if(key.equals("emptyweightbox")){
		            		pd.put("EMPTY_WEIGHT_BOX", idField);
		            	}else if(key.equals("subsupplier")){//分供方
		            		pd.put("SUB_SUPPLIER_ID", idField);
		            		pd.put("SUB_SUPPLIER", textField);
		            	}else if(key.equals("price_source")){//价格来源
		            		pd.put("PRICE_SOURCE", idField);	            		
		            	}
		   	           
		            }
		           
		         
		         
		        } 
		          int packtype=-1;
		            if(pd.get("IS_FACTORYPACKING")!=null && pd.get("IS_FACTORYPACKING").equals("0"))
		            {
		            	packtype=0;
		            }
		           if(pd.get("IS_HARBOURPACKING")!=null && pd.get("IS_HARBOURPACKING").equals("1"))
	              {
	            	  if(packtype==0){
	            		  packtype=2;
	            	  }else if(packtype==-1)
	            	  {
	            		  packtype=1;
	            	  }
	            		  
	              }
		          pd.put("BOX_LOAD_TYPE", packtype);
		          
		        String USERNAME = Jurisdiction.getUsername();//当前登录的用户名        	
		        //System.out.println("a");
				JSONObject obj = new JSONObject();
				
				String flag = consignInputService.consignUpdate(pd);	
			 
				if("1".equals(flag)){//托单保存成功将托单编号写入流水号表中
					Map<String,String> parma=new HashMap<String,String>();
					parma.put("businessType",billCode.substring(6,8));
					parma.put("billCode", billCode);
					consignInputService.consignFlowNumUpdate(parma);
				}
				if("1".equals(flag) && "2".equals(isTrailer))//委托拖车
	        	{
					Map<String, String> map =new HashMap<String,String>();
					map.put("billCode", billCode);
					//trailerList.add(map);
					int trailerNum = consignInputService.getTrailerNum(map);
					if(trailerNum>0){
						consignInputService.deleteTrailer(map);
					}
					if(trailerList.size()>0)
	        		consignInputService.trailerInsert(trailerList);
	        	}
				if(!boxList.isEmpty()){
					
					consignInputService.boxtypeNumInsert(boxList);
				}
				JSONArray json = new JSONArray();
	            if("1".equals(flag))
	            {
	            	json.add("SUCCESS");
	            }
	            response.setContentType("text/html; charset=utf-8");
				response.getWriter().write(json.toString());	 				
				response.getWriter().flush();
	    	  }catch(Exception ex){
	    		ex.printStackTrace();
	    	  }
			
	    }
	    
	    @RequestMapping(value="/selectDangerous")
	    public void selectDangerous(Page page,HttpServletRequest request,HttpServletResponse response) throws Exception{
	    	PageData pd = new PageData();
	    	pd = this.getPageData();		
			
	    	PageData o = consignInputService.selectDangerous(pd);	    	
            response.setContentType("text/html; charset=utf-8");
			response.getWriter().write(o.toString());	 				
			response.getWriter().flush();
	    }
	    
	   
	    @InitBinder
		public void initBinder(WebDataBinder binder){
			DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
			binder.registerCustomEditor(Date.class, new CustomDateEditor(format,true));
		}
	}
